<template>
  <div class="goodsDetail">
    <div>
      <div class="mt20 bsid">
        <span class="main_active">{{ translate('基站编码') }}：</span>
        <el-input v-model="formInfo.bsid" class="w400" :disabled="isedit" />
        <!-- <div class="stitle">
          <input
            v-for="(item, index) in inputList"
            :key="item"
            v-model="item.pinless"
            class="honderd"
            :disabled="isedit"
            label=""
            @keydown="expurgate(index)"
            @keyup="keyboard($event, index)"
          />
        </div> -->
      </div>
      <div class="mt20">
        <span class="main_active">{{ translate('密钥') }}：</span>
        <el-input v-model="formInfo.code" class="w400" :disabled="isedit" />
      </div>
      <div class="mt20">
        <span class="main_active">{{ translate('基站名称') }}：</span>
        <el-input v-model="formInfo.bsName" class="w400" />
      </div>
      <div class="mt20">
        <span class="main_active">{{ translate('版本号') }}：</span>
        <el-input v-model="formInfo.version" class="w400" />
      </div>
      <div class="mt20">
        <span class="main_active">{{ translate('备注') }}：</span>
        <el-input v-model="formInfo.remark" class="w400" />
      </div>
      <div class="mt20">
        <span class="main_active">{{ translate('状态') }}：</span>
        <el-switch
          v-model="formInfo.status"
          :active-text="translate('正常')"
          :active-value="1"
          :inactive-text="translate('禁用')"
          :inactive-value="0"
        />
      </div>
    </div>
  </div>
</template>
<script>
  import { translate } from '@/i18n'
  export default {
    name: 'Detail',
    components: {},
    props: {
      form: {
        type: Object,
        default: () => {
          return {}
        },
      },
      isedit: {
        type: Boolean,
        default: false,
      },
    },
    emits: ['deletedchild'],
    data() {
      return {
        formInfo: this.form,
        translate: translate,
        inputList: this.form.bsidarr,
      }
    },
    watch: {
      form(val) {
        this.formInfo = val
        this.inputList = val.bsidarr
      },
    },
    methods: {
      keyboard(e, index) {
        const domNode = document.getElementsByClassName('honderd'),
          currInput = domNode[index],
          nextInput = domNode[index + 1],
          lastInput = domNode[index - 1]
        console.log(domNode, 'domNodedomNode')
        if (e.keyCode != 8) {
          console.log(currInput.value)
          console.log(nextInput)
          if (index <= this.inputList.length - 1) {
            if (currInput.value.length >= 2) {
              if (!nextInput) {
                currInput.blur()
              } else {
                nextInput.focus()
              }
            }
          } else {
            currInput.blur()
            console.log(nextInput, 'nextInput')
          }
        } else {
          if (index != 0) {
            lastInput.focus()
          }
        }
      },
      expurgate(index) {
        console.log(this.inputList)
        if (this.inputList[index].pinless.length >= 2) {
          this.inputList[index].pinless = ''
        }
      },
    },
  }
</script>
<style lang="scss" scoped>
  .goodsDetail {
    height: 300px;
  }
  .flex_align {
    display: flex;
    align-items: center;
  }
  .tableDetail {
    padding: 10px;
    .button-add {
      text-align: end;
      padding: 10px;
    }
  }
  .main_active {
    display: inline-block;
    width: 120px;
    text-align: right;
  }
  .mr20 {
    margin-right: 20px;
  }

  .w400 {
    width: 400px !important;
  }
  .mt20 {
    margin-top: 10px;
  }
  .mr10 {
    margin-right: 10px;
  }
  .w320 {
    width: 320px;
  }
  .bsid {
    display: flex;
    justify-content: left;
    align-items: center;
  }
  .honderd {
    width: 40px;
    height: 35px;
    border: 1px solid #cacaca;
    text-align: center;
    font-size: 16px;
    font-weight: 400;
    color: #3d3d3d;
    border-right: none;
    :deep(.van-field__control) {
      text-align: center;
    }
  }
  .stitle .honderd:last-child {
    border-right: 1px solid #cacaca;
  }
  ::v-deep .el-scrollbar__wrap {
    overflow-x: auto;
    height: calc(100% + 20px); //多出来的20px是横向滚动条默认的样式
  }
  ::v-deep .el-scrollbar .el-scrollbar__wrap .el-scrollbar__view {
    white-space: nowrap;
    display: inline-block;
  }
  ::v-deep .el-table--scrollable-x .el-table__body-wrapper {
    overflow-x: hidden;
  }
  ::v-deep input[type='number']::-webkit-inner-spin-button,
  ::v-deep input[type='number']::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
  }
</style>
